<?php

/**
 * Mp form base class.
 *
 * @method Mp getObject() Returns the current form's model object
 *
 * @package    explications_informatiques
 * @subpackage form
 * @author     Guimezanes Cyrille
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseMpForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'idmp'            => new sfWidgetFormInputHidden(),
      'id_auteur'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'add_empty' => true)),
      'id_destinataire' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'add_empty' => true)),
      'sujet'           => new sfWidgetFormInputText(),
      'message'         => new sfWidgetFormTextarea(),
      'date'            => new sfWidgetFormDateTime(),
      'lu'              => new sfWidgetFormInputText(),
      'suppr_author'    => new sfWidgetFormInputText(),
      'suppr_desti'     => new sfWidgetFormInputText(),
      'topic'           => new sfWidgetFormInputText(),
      'spam'            => new sfWidgetFormInputText(),
      'online'          => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'idmp'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idmp')), 'empty_value' => $this->getObject()->get('idmp'), 'required' => false)),
      'id_auteur'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile'), 'required' => false)),
      'id_destinataire' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('SfGuardUserProfile_2'), 'required' => false)),
      'sujet'           => new sfValidatorString(array('max_length' => 150, 'required' => false)),
      'message'         => new sfValidatorString(array('required' => false)),
      'date'            => new sfValidatorDateTime(array('required' => false)),
      'lu'              => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'suppr_author'    => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'suppr_desti'     => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'topic'           => new sfValidatorInteger(array('required' => false)),
      'spam'            => new sfValidatorString(array('max_length' => 1, 'required' => false)),
      'online'          => new sfValidatorString(array('max_length' => 1, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('mp[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Mp';
  }

}
